<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学IT - 后台管理系统</title>
    <?php include( './views/common/style.html' ) ?>
</head>
<body>
    <!-- 登录 -->
    <div class="login">
        <div class="login-wrap">
            <div class="avatar">
                <img src="/assets/images/default.png" class="img-circle" alt="">
            </div>
            <form id="formId" class="col-md-offset-1 col-md-10">
                <div class="input-group input-group-lg">
                    <span class="input-group-addon">
                        <i class="fa fa-user"></i>
                    </span>
                    <input type="text" 
                           name="tc_name" 
                           value="前端学院" 
                           class="form-control" 
                           placeholder="用户名">
                </div>
                <div class="input-group input-group-lg">
                    <span class="input-group-addon">
                        <i class="fa fa-key"></i>
                    </span>
                    <input type="password" 
                           name="tc_pass"
                           value="123456"
                           class="form-control" 
                           placeholder="密码">
                </div>
                <button type="submit" class="btn btn-lg btn-primary btn-block">登 录</button>
            </form>
        </div>
    </div>
    
    <?php include( './views/common/script.html' ) ?>
    <script>

        //模块化  就需使用 require([""]);
      require( [ 'login' ] );

       /* $('#formId').on('submit',function(){
            //收集数据 tc_name = zs$tc_pass =123
            var formData = $(this).serialize();
            console.log(formData);

            //发送ajax请求
            $.ajax({
                url:'/api.login',
                type:'post',
                data:formData,
                success:function(info){
                    console.log(info);
                    if(info.code ==200){
                        alert('登录成功');
                        //数据保存到cookie 中
                        $.cookie('userInfo',JSON.stringify(info.result),{path:'/'});
                        location.pathname = '/';
                    }
                }
            })

            return false;

        })*/

        //做登录
        /*
        * 填写用户名和密码
        * 发送ajax请求到后台，后台会返回数据
        *
        * */

//        $("#formId").on("submit",function(){
//            //serialize()  让上面的账号 密码 拼接成字符串
//            var formData = $(this).serialize();
//              console.log(formData);
//
//            $.ajax({
//                url:'/api/login',
//                data:formData,
//                type:'post',
//                success:function(info){
//                    console.log(info);
//                    if(info.code ==200){
//                        alert("登录成功！");
//                        //将数据保存到cookie中
//
//                        //JSON.stringify  将json对象转化为字符串
//                        $.cookie("userInfo",JSON.stringify(info.result),{path:'/'});
//                        location.pathname = "/";
//                    }
//                }
//            })
//
//
//            return false;
//        })

    </script>
</body>
</html>